package com.nameli.admin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nameli.SIM.bean.entity.DepartmentInfo;
import com.nameli.SIM.bean.query.DepartQuery;
import com.nameli.SIM.bean.vo.DepartmentVO;
import com.nameli.SIM.bean.vo.MajorInfoVO;
import com.nameli.SIM.mapper.DepartmentInfoMapper;
import com.nameli.SIM.util.EmptyUtil;
import com.nameli.admin.service.DepartMentService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


import java.util.List;
import java.util.Map;

/**
 * @author NAME-L
 * @Description 学部 serviceImpl
 * @className DepartMentInfoServiceImpl
 * @date 2021-11-05 14:31:54
 */
@Component
public class DepartMentServiceImpl implements DepartMentService {

    private static final Log log = LogFactory.getLog(DepartMentServiceImpl.class);

    @Autowired
    private DepartmentInfoMapper departmentInfoMapper;


    @Override
    public List<Map<String, Object>> queryByDepartMentNo() {
        log.info("enter into -----------> DepartMentServiceImpl - queryByDepartMentNo");
        List<Map<String, Object>> list = departmentInfoMapper.queryByDepartMentNo();
        if(list != null || list.size() > 0){
            log.info("check -----------> list大小不为空");
            return list;
        }
        log.info("check -----------> list为空");
        return null;
    }

    @Override
    public PageInfo<DepartmentVO> queryAllDepart(Integer pageIndex, Integer pageSize) {
        log.info("enter into -----------> DepartMentServiceImpl - queryAllDepart");
        log.info("pageIndex:"+pageIndex);
        log.info("pageSize:"+pageSize);
        PageHelper.startPage(pageIndex, pageSize);
        List<DepartmentVO> departmentVOS = departmentInfoMapper.queryAllDepart();
        log.info("output -----------> departmentVOS:" + departmentVOS);
        PageInfo<DepartmentVO> departmentVOPageInfo = new PageInfo<>(departmentVOS);
        return departmentVOPageInfo;
    }

    @Override
    public PageInfo<DepartmentVO> queryByCondition(DepartQuery departQuery, Integer pageIndex, Integer pageSize) {
        log.info("enter into -----------> DepartMentServiceImpl - queryByCondition");
        log.info("pageIndex:"+pageIndex);
        log.info("pageSize:"+pageSize);
        PageHelper.startPage(pageIndex, pageSize);
        List<DepartmentVO> departMentVOS = departmentInfoMapper.queryByCondition(departQuery);
        log.info("output -----------> departmentVOS:" + departMentVOS);
        PageInfo<DepartmentVO> departmentVOPageInfo = new PageInfo<>(departMentVOS);
        return departmentVOPageInfo;
    }

    @Override
    public List<DepartmentInfo> queryDepart() {
        log.info("enter into -----------> DepartMentServiceImpl - queryDepart");
        List<DepartmentInfo> infoList = departmentInfoMapper.queryDepart();
        return infoList;
    }


}
